﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BoAddonBiz_FreightForwarder.BusinessBase;
using SAPbouiCOM;
using SAPbobsCOM;
using System.Text.RegularExpressions;

namespace BoAddonBiz_FreightForwarder.Sea
{
    [ControlB1Form(IsNew = true, FormType = B1FormTypes.ado_AVA_SE_Prealert)]
    class B1Form_Prealert_Sea : B1Form_BusinessOperation_Base
    {
        #region override
        protected override string AVA_OBNO { get { return "@AVA_SE_OPRE"; } }
        protected override string AVA_BNO1 { get { return "@AVA_SE_PRE1"; } }
        protected override string AVA_BNO2 { get { return "@AVA_SE_PRE2"; } }
        protected override string AVA_BNO3 { get { return "@AVA_SE_PRE3"; } }
        protected override string AVA_BNO4 { get { return "@AVA_SE_PRE4"; } }
        protected override string AVA_BNO5 { get { return "@AVA_SE_PRE5"; } }
        protected override string AVA_ODLG { get { return "@AVA_SE_ODLG"; } }
        protected override string AVA_DLG1 { get { return "@AVA_SE_DLG1"; } }
        protected override string AVA_DLG2 { get { return "@AVA_SE_DLG2"; } }
        protected override string AVA_DLG3 { get { return "@AVA_SE_DLG3"; } }
        protected override string AVA_DLG6 { get { return "@AVA_SE_DLG6"; } }
        private string AVA_BNO6 { get { return "@AVA_SE_PRE6"; } }
        protected override string AVA_AirOrder { get { return "AVA_FF_AirOrder"; } }
        protected override string AVA_AirOrderUsed { get { return "AVA_FF_AirOrderUsed"; } }
        protected override string AVA_OAOU { get { return "@AVA_FF_OAOU"; } }
        protected override string AVA_OAOD { get { return "@AVA_FF_OAOD"; } }
        protected override string SourceObject { get { return "AVA_SE_Delegate"; } }
        protected override string BusinessType { get { return "SE"; } }
        protected override string[] SumMapping
        {
            get { return new string[] { "U_Quantity:U_Quantity", "U_GrossWeight:U_GrossWeight", "U_BillingWeight:U_BillingWeight", "U_Volume:U_Volume", "U_CargoValue:U_InvoiceValue" }; }
        }
        protected override string[] CB_LABEL_UDS_DBDS_OBJECT_TABLE_DESC
        {
            get
            {
                return new string[] {
            "cb_opup:btn_opup:OPUP_UID:U_IsPickup:AVA_SE_Pickup:@AVA_SE_OPUP:提货",
            "cb_oisu:btn_oisu:OISU_UID:U_IsInsure:AVA_SE_Insure:@AVA_SE_OISU:投保",            
            "cb_oatc:btn_oact:OATC_UID:U_IsCustoms:AVA_SE_ApplyCustoms:@AVA_SE_OATC/@AVA_SE_ATC1:出口报关/报检",
            "cb_ostg:btn_ostg:OSTG_UID:U_IsWarehouse:AVA_SE_Storage:@AVA_SE_OSTG/@AVA_SE_STG1:仓储",
            "cb_odlv:btn_odlv:ODLV_UID:U_IsDelivery:AVA_SE_Deliver:@AVA_SE_ODLV:送货",
            "cb_octc:btn_octc:OCTC_UID:U_IsClearance:AVA_SE_Clearance:@AVA_SE_OCTC/@AVA_SE_CTC1:进口报关/报检",
            "cb_oarp:btn_oarp:OARP_UID:U_IsArrivePort:AVA_SE_ArrivePort:@AVA_SE_OARP:到港",
            "cb_opck:btn_opck:OPCK_UID:U_IsBox:AVA_SE_Packing:@AVA_SE_OPCK/@AVA_SE_PCK1/@AVA_SE_PCK2:装箱"
            };
            }
        }

        #endregion
        #region constractor
        public B1Form_Prealert_Sea()
        {
            this.frm_ItemEvent += new SAPBoAddon.IB1FormEvents.B1ItemEventEventHandler(B1Form_BusinessOpera_Sea_frm_ItemEvent);
            this.frm_FormDataEvent += new SAPBoAddon.IB1FormEvents.B1FormDataEventEventHandler(B1Form_BusinessOpera_Sea_frm_FormDataEvent);
            this.frm_MenuEvent += new SAPBoAddon.IB1FormEvents.B1MenuEventEventHandler(B1Form_BusinessOpera_Sea_frm_MenuEvent);
            this.frm_ChooseFormListEvent += new SAPBoAddon.IB1FormEvents.B1ChooseFormListEventEventHandler(B1Form_BusinessOpera_Sea_frm_ChooseFormListEvent);
        }
        #endregion
        #region protected override
        protected override void FormInfoSetting(SAPBoAddon.B1FormSetting FormSetting)
        {
            FormSetting.FormType = B1FormTypes.ado_AVA_SE_Prealert;
            FormSetting.FormFileName = B1FormTypes.ado_AVA_SE_Prealert + ".srf";
            #region 控件的可编辑状态
            FormSetting.FormModeSetting.StatusItemUID = "7";
            SAPBoAddon.BrowseModeSetting BrowseModeSetting;
            #region R状态
            string[] ItemList;
            string[] filter = new string[] { "btn_Send", "btn_Fee", "CaPrevious", "CargoNext", "CarSurvey", "PtPrevious", "PortNext", "PrtSurvey", "FlPrevious", "FileNext", "FleSurvey" };
            string[] FileItems = new String[] { "334", "340", "342", "344", "350", "336", "346", "352", "338", "348", "354", "356", "Upload", "FileAdd", "FileDel", "105"/*目的港ATA*/ };
            ItemList = new string[FileItems.Length + filter.Length];
            FileItems.CopyTo(ItemList, 0);
            filter.CopyTo(ItemList, FileItems.Length);
            BrowseModeSetting = FormSetting.FormModeSetting.BrowseModeSettingList.Add();
            BrowseModeSetting.Status = "R";
            BrowseModeSetting.itmBrowseModeEnable = FileItems;
            BrowseModeSetting.itmBrowseModeDisable = Utils.GetFormItems(FormSetting.FormXmlDocument, true, ItemList);
            #endregion

            #endregion
            base.FormInfoSetting(FormSetting);
            #region Matrix
            //配置添加子表的行
            FormSetting.MatrixSetting.MtxUID = "mtxService";
            FormSetting.MatrixSetting.NotAllowNoLineSave = false;
            FormSetting.MatrixSetting.AutoAddNewLine = true;
            FormSetting.MatrixSetting.MenuAddNewLine = false;
            FormSetting.MatrixSetting.AutoLineKeyCol = "col_1";//箱型
            FormSetting.MatrixSetting.BeforeSaveDeleteNoValueLine = false;
            FormSetting.MatrixSetting.BeforeSaveFixDbDataSourceData = false;
            FormSetting.MatrixSetting.TableKeyField = "LineId";
            FormSetting.MatrixSetting.TableVisOrder = "VisOrder";
            FormSetting.MatrixSetting.PrimaryLineCol = "col_f";
            FormSetting.MatrixSetting.TableName = AVA_BNO6;
            FormSetting.MatrixSetting.Add();
            #endregion
        }
        protected override void FormEditModeChange(SAPBoAddon.frmItemEditMode frmEditMode)
        {
            base.FormEditModeChange(frmEditMode);

            switch (frmEditMode)
            {
                case SAPBoAddon.frmItemEditMode.fe_AddMode:
                    this.CurrentForm.Items.Item("FCL").Click(BoCellClickType.ct_Regular);
                    break;
            }
        }
        protected override void InitializeForm(SAPBoAddon.B1FormInitializePar InitPar)
        {
            SAPbobsCOM.Recordset oRst = SBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
            base.InitializeForm(InitPar);
            Utils.InitialMatrixComboBox(this.SBOCompany, this.CurrentForm.Items.Item("mtxService").Specific, "col_1", "Code", "Name", "@AVA_FF_OBOX", "Code", null, null, true, true);//服务的箱型
            Utils.InitialItemComboBox(this.SBOCompany, this.CurrentForm.Items.Item("cargo_46"), "Code", "Name", "@AVA_FF_OPRI", "Code", null, "U_Type = N'Number' OR U_Type = N'Pack'", true, false, true);// 包装形式 取值 计量单位里的 by WangPeng 2012年8月29日 19:35:07
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oRst);

            (this.CurrentForm.Items.Item("mtxService").Specific as Matrix).LoadFromDataSource();
            switch (this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_ContainerType", 0).Trim())
            {
                case "FCL":
                case "1":
                    this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).GetValue("U_BoxQty", 0));
                    break;
                case "LCL":
                case "2":
                    this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, "LCL");
                    break;
                case "BREAKBULK":
                case "3":
                    this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, "BULK");
                    break;
            }
        }
        /// <summary>
        /// 初始化下拉列表
        /// </summary>
        /// <author>WangPeng</author>
        protected override void Combobox_Initialize()
        {
            SAPbobsCOM.Recordset oRst = SBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
            Utils.ComboBox_Cargo_Initial(oRst, this.CurrentForm, Cargo_ComboBoxUID_Field);
            Utils.ComboBox_Main_Initial(oRst, this.CurrentForm, BnsOperation_ComboBoxUID_Field);
            Utils.ComboBox_InitialItem(oRst, CurrentForm.Items.Item("1000051"), "Code", "Name", "@AVA_SE_TSCL", "Code", null, true, true);//运输方式
            Utils.InitialItemComboBox(this.SBOCompany, this.CurrentForm.Items.Item("336"), "Code", "Name", "@AVA_FF_DTYP", "CAST(Code AS INT)");//文件类型  暂时注释 By WangPeng 2012年8月13日 16:51:00
        }
        #endregion
        #region Events
        void B1Form_BusinessOpera_Sea_frm_ChooseFormListEvent(SAPBoAddon.B1AddonBase.B1ChooseFormList pVal, ref bool BubbleEvent)
        {
            SAPbouiCOM.DBDataSource dbds = default(SAPbouiCOM.DBDataSource);
            SAPbouiCOM.Conditions cons;
            SAPbouiCOM.Condition con;
            SAPbouiCOM.ChooseFromList cfl;
            SAPbobsCOM.Recordset oRst = (SAPbobsCOM.Recordset)SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

            if (pVal.Before_Action)
            {
                cfl = this.CurrentForm.ChooseFromLists.Item(pVal.ChooseFromListUID);
                switch (pVal.ChooseFromListUID)
                {
                    case "CFL_BookingAgentCardCode"://订舱代理
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup4";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup5";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup7";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup13";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_F"://承运人
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup4";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_TP"://中转港代理
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup7";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup13";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_T":
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup7";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup13";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_ED"://目的港代理
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup7";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup11";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup12";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup13";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_SD"://起运港代理
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup7";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup11";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup12";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup13";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_S"://发货人
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup11";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup12";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                    case "CFL_OCRD_R"://收货人
                        cons = new SAPbouiCOM.Conditions();
                        con = cons.Add();
                        con.Alias = "QryGroup11";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_OR;
                        con = cons.Add();
                        con.Alias = "QryGroup12";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        con.Relationship = BoConditionRelationship.cr_AND;
                        con = cons.Add();
                        con.Alias = "validFor";
                        con.CondVal = "Y";
                        con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                        cfl.SetConditions(cons);
                        break;
                }
            }
            else
            {
                switch (pVal.ChooseFromListUID)
                {
                    case "CFL_BookingAgentCardCode"://订舱代理
                        dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO);
                        dbds.SetValue("U_BookingAgentCode", dbds.Offset, pVal.SelectedObjects.GetValue("CardCode", 0).ToString());
                        dbds.SetValue("U_BookingAgentName", dbds.Offset, string.IsNullOrEmpty(pVal.SelectedObjects.GetValue("CardName", 0).ToString()) ? pVal.SelectedObjects.GetValue("CardFName", 0).ToString() : pVal.SelectedObjects.GetValue("CardName", 0).ToString());
                        break;

                    case "CFL_PORT_R"://订舱代理
                        dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO);
                        dbds.SetValue("U_ReceiptPortCode", dbds.Offset, pVal.SelectedObjects.GetValue("DocEntry", 0).ToString());
                        dbds.SetValue("U_ReceiptPortThCode", dbds.Offset, pVal.SelectedObjects.GetValue("U_PortCode", 0).ToString());
                        dbds.SetValue("U_ReceiptPort", dbds.Offset, pVal.SelectedObjects.GetValue("U_PortNameE", 0).ToString());
                        break;

                    case "CFL_OCRD_R"://收货人
                        dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO);
                        dbds.SetValue("U_ReceiverCode", dbds.Offset, pVal.SelectedObjects.GetValue("CardCode", 0).ToString());
                        dbds.SetValue("U_Receiver", dbds.Offset, string.IsNullOrEmpty(pVal.SelectedObjects.GetValue("CardName", 0).ToString()) ? pVal.SelectedObjects.GetValue("CardFName", 0).ToString() : pVal.SelectedObjects.GetValue("CardName", 0).ToString());
                        break;
                    case "CFL_OCRD_S"://发货人
                        dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO);
                        dbds.SetValue("U_SenderCode", dbds.Offset, pVal.SelectedObjects.GetValue("CardCode", 0).ToString());
                        dbds.SetValue("U_Sender", dbds.Offset, string.IsNullOrEmpty(pVal.SelectedObjects.GetValue("CardName", 0).ToString()) ? pVal.SelectedObjects.GetValue("CardFName", 0).ToString() : pVal.SelectedObjects.GetValue("CardName", 0).ToString());
                        break;
                }
            }
        }

        void B1Form_BusinessOpera_Sea_frm_MenuEvent(SAPBoAddon.B1AddonBase.B1MenuEvent pVal, ref bool BubbleEvent)
        {
            if (pVal.BeforeAction)
            {
                if (pVal.MenuUID == "1292")//添加行
                {
                    if (this.CurrentForm.Settings.MatrixUID == "mtxService")
                    {
                        Matrix mtx = this.CurrentForm.Items.Item(this.CurrentForm.Settings.MatrixUID).Specific;
                        SAPBoAddon.B1Assistant.Matrix.AutoAddNewLine(CurrentForm, this.CurrentForm.Settings.MatrixUID, "col_f", mtx.Columns.Item("col_f").DataBind.TableName, -1, "LineId", "VisOrder", true);
                    }
                }
                else if (pVal.MenuUID == "1293")//删除行
                {
                    if (this.CurrentForm.Settings.MatrixUID == "mtxService")
                    {
                        Matrix mtx = this.CurrentForm.Items.Item(this.CurrentForm.Settings.MatrixUID).Specific;
                        if (mtx.GetCellFocus() != null)
                        {
                            SAPBoAddon.B1Assistant.Matrix.DeleteRowAndDbdsLine(CurrentForm, mtx.Columns.Item("col_f").DataBind.TableName, "LineId", this.CurrentForm.Settings.MatrixUID, "col_f", mtx.GetCellFocus().rowIndex, true);
                            this.CurrentForm.Freeze(true);
                            (this.CurrentForm.Items.Item("mtxService").Specific as Matrix).FlushToDataSource();
                            Utils.SetBoxAndCargoQuantityDescription(SBOApp, this.CurrentForm.UniqueID, new Arabic2Engish().NumberToString, "", AVA_OBNO);
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).GetValue("U_BoxQty", 0));
                            this.CurrentForm.Freeze(false);
                        }
                    }
                }
            }
            else
            {
                if (pVal.MenuUID == "1287")//复制
                {
                    this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_IsBox", 0, "N");//装箱
                }
            }
        }

        void B1Form_BusinessOpera_Sea_frm_FormDataEvent(SAPBoAddon.B1AddonBase.B1BusinessObjectInfo pVal, ref bool BubbleEvent)
        {
            if (pVal.BeforeAction)
            {
                if (pVal.EventType == BoEventTypes.et_FORM_DATA_UPDATE || pVal.EventType == BoEventTypes.et_FORM_DATA_ADD)
                {
                    //SAPbouiCOM.DBDataSource dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO);
                    //string ContainerType = dbds.GetValue("U_ContainerType", dbds.Offset).Trim();
                    //SAPbouiCOM.Matrix mtx_Service = this.CurrentForm.Items.Item("mtxService").Specific;

                    //if (ContainerType == "2")//LCL
                    //{
                    //    mtx_Service.Clear();
                    //    mtx_Service.FlushToDataSource();
                    //}
                }
            }
            else
            {
                this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6).Offset = 0;
                if (pVal.EventType == BoEventTypes.et_FORM_DATA_LOAD)
                {
                    if (new string[] { "21", "22" }.Contains(CurrentForm.PaneLevel.ToString()))
                    {
                        switch (this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_ContainerType", 0).Trim())
                        {
                            case "FCL":
                            case "1":
                                CurrentForm.PaneLevel = 21;
                                break;
                            case "LCL":
                            case "2":
                                CurrentForm.PaneLevel = 22;
                                break;
                            case "BREAKBULK":
                            case "3":
                                CurrentForm.PaneLevel = 22;
                                break;
                            default:
                                CurrentForm.PaneLevel = 21;
                                break;
                        }
                    }
                    //设置分单页签是否显示
                    this.SetTabHidden("914_1", "tab_4");
                }
            }
        }

        void B1Form_BusinessOpera_Sea_frm_ItemEvent(SAPBoAddon.B1AddonBase.B1ItemEvent pVal, ref bool BubbleEvent)
        {
            if (pVal.Before_Action)
            {
                if (new string[] { "1000054", "1000058" }.Contains<string>(pVal.ItemUID) && pVal.EventType == BoEventTypes.et_VALIDATE)
                {
                    string value = this.CurrentForm.Items.Item(pVal.ItemUID).Specific.Value;
                    if (Regex.IsMatch(value, @"^\d+$"))
                    {
                        this.CurrentForm.Items.Item(pVal.ItemUID).Specific.Value = String.Format("{0}({1})", new Arabic2Engish().NumberToString(Convert.ToDouble(value)), value);
                    }
                }
                if (pVal.ItemUID == "1" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    if (this.CurrentForm.Mode != BoFormMode.fm_OK_MODE)
                    {
                        DBDataSource dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6);
                        System.Data.DataTable dt = SAPBoAddon.B1Assistant.DBDataSource.ReturnDotNetDataTable(dbds);
                        if (SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, "FCL").ToString() == "Y")/*modified by WangPeng 2012-6-5*/
                        {
                            SAPBoAddon.B1Assistant.Matrix.RemoveNoValueLines(this.CurrentForm, "mtxService", "col_f", "col_1", AVA_BNO6, "LineId");
                            (this.CurrentForm.Items.Item("mtxService").Specific as Matrix).FlushToDataSource();
                        }
                        (this.CurrentForm.Items.Item("mtxService").Specific as Matrix).LoadFromDataSource();

                        dbds.Offset = 0;

#if DEBUG
                        System.Data.DataTable table = SAPBoAddon.B1Assistant.DBDataSource.ReturnDotNetDataTable(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6));
#endif
                    }
                }
            }
            else
            {
                if (pVal.ItemUID == "1" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    DBDataSource dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6);
                    dbds.Offset = 0;
                }
                #region 事件后
                #region Switch Panel
                if (pVal.ItemUID == "tab_0" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    SwitchServiceTab();
                }
                if (pVal.ItemUID == "tab_1" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    CurrentForm.PaneLevel = 2;
                }
                if (pVal.ItemUID == "tab_2" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    CurrentForm.PaneLevel = 3;
                }
                if (pVal.ItemUID == "tab_3" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    CurrentForm.PaneLevel = 4;
                }
                if (pVal.ItemUID == "tab_4" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    CurrentForm.PaneLevel = 5;
                }
                if (pVal.ItemUID == "tabService" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    SwitchServiceTab();
                }
                if (pVal.ItemUID == "tab_4" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    Utils.SetBoxAndCargoQuantityDescription(SBOApp, this.CurrentForm.UniqueID, new Arabic2Engish().NumberToString, "", AVA_OBNO);
                }
                if (pVal.ItemUID == "FCL" && pVal.EventType == BoEventTypes.et_CLICK)
                {
                    CurrentForm.PaneLevel = 21;
                    if (this.CurrentForm.Mode == BoFormMode.fm_ADD_MODE || this.CurrentForm.Mode == BoFormMode.fm_UPDATE_MODE || this.CurrentForm.Mode == BoFormMode.fm_OK_MODE)
                    {
                        this.CurrentForm.Freeze(true);
                        //ClearDBDS(); //add by WangPeng 2012年11月23日 14:45:29
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).SetValue("U_ShippingClause", 0, "SHIPPER'S LOAD , COUNT & SEAL");
                        Utils.SetBoxAndCargoQuantityDescription(SBOApp, this.CurrentForm.UniqueID, new Arabic2Engish().NumberToString, "1", AVA_OBNO);
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).GetValue("U_BoxQty", 0));
                        this.CurrentForm.Freeze(false);
                    }
                }
                if (pVal.ItemUID == "LCL" && pVal.EventType == BoEventTypes.et_CLICK)
                {
                    CurrentForm.PaneLevel = 22;
                    if (this.CurrentForm.Mode == BoFormMode.fm_ADD_MODE || this.CurrentForm.Mode == BoFormMode.fm_UPDATE_MODE || this.CurrentForm.Mode == BoFormMode.fm_OK_MODE)
                    {
                        this.CurrentForm.Freeze(true);
                        //ClearDBDS();
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).SetValue("U_ShippingClause", 0, "");
                        Utils.SetBoxAndCargoQuantityDescription(SBOApp, this.CurrentForm.UniqueID, new Arabic2Engish().NumberToString, "2",AVA_OBNO);
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, "LCL");
                        this.CurrentForm.Freeze(false);
                    }
                }
                if (pVal.ItemUID == "BULK" && pVal.EventType == BoEventTypes.et_CLICK)
                {
                    CurrentForm.PaneLevel = 23;
                    if (this.CurrentForm.Mode == BoFormMode.fm_ADD_MODE || this.CurrentForm.Mode == BoFormMode.fm_UPDATE_MODE || this.CurrentForm.Mode == BoFormMode.fm_OK_MODE)
                    {

                        this.CurrentForm.Freeze(true);
                        //ClearDBDS();
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).SetValue("U_BoxQty", 0, "");
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).SetValue("U_BoxQtyTotalDesc", 0, "");
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).SetValue("U_ShippingClause", 0, "");
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, "BULK");
                        this.CurrentForm.Freeze(false);
                    }
                }
                #endregion
                if (this.CurrentForm.Mode == BoFormMode.fm_ADD_MODE || this.CurrentForm.Mode == BoFormMode.fm_UPDATE_MODE)
                {
                    #region 点击“自拼”时激活明细控件
                    if (pVal.ItemUID == "Chk_In" && (pVal.EventType == BoEventTypes.et_ITEM_PRESSED || pVal.ItemChanged))
                    {
                        this.CurrentForm.Items.Item("T_Company").Enabled = false;
                        if (SAPBoAddon.B1Assistant.Item.GetValue(CurrentForm, pVal.ItemUID).ToString().Trim() == "Y")
                        {
                            this.CurrentForm.Items.Item("T_Company").Enabled = true;
                        }
                    }
                    #endregion

                    #region 海运特有，改变单件重量的时候同时计算计费重

                    if (pVal.EventType == BoEventTypes.et_COMBO_SELECT && new string[] { "cargo_30", "cargo_72" }.Contains<string>(pVal.ItemUID))
                    {
                        Utils.CalculateVolumeAndQuantity(SBOApp, SBOCompany, CurrentForm, AVA_BNO1, CargoCurrentOffset);
                    }
                    if (new string[] { "cargo_56", "cargo_62", "cargo_68", "cargo_40" }.Contains<string>(pVal.ItemUID) && pVal.ItemChanged)
                    {

                        string value = string.Empty;
                        switch (pVal.ItemUID)
                        {
                            case "cargo_56"://订单金额
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_TraAmount", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_62"://合同金额
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_ConAmount", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_68"://发票金额
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_InvoiceValue", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_40"://货值
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_CargoValue", CargoCurrentOffset).Trim();
                                break;
                        }
                        double origin = 0.0d;
                        double.TryParse(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_TraAmount", CargoCurrentOffset), out origin);
                        if (origin == 0.0d)
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_TraAmount", CargoCurrentOffset, value);
                        }
                        double.TryParse(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_ConAmount", CargoCurrentOffset), out origin);
                        if (origin == 0.0d)
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_ConAmount", CargoCurrentOffset, value);
                        }
                        double.TryParse(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_InvoiceValue", CargoCurrentOffset), out origin);
                        if (origin == 0.0d)
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_InvoiceValue", CargoCurrentOffset, value);
                        }
                        double.TryParse(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_CargoValue", CargoCurrentOffset), out origin);
                        if (origin == 0.0d)
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_CargoValue", CargoCurrentOffset, value);
                        }

                        Utils.MaterialSum(this.CurrentForm, AVA_OBNO, AVA_BNO1, SumMapping);
                    }
                    if (new string[] { "cargo_58", "cargo_64", "cargo_70", "cargo_42" }.Contains<string>(pVal.ItemUID) && pVal.EventType == BoEventTypes.et_COMBO_SELECT)
                    {
                        string value = string.Empty;
                        switch (pVal.ItemUID)
                        {
                            case "cargo_58"://订单币种
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_TraCurrency", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_64"://合同币种
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_ConCurrency", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_70"://发票币种
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_InvoiceCurrency", CargoCurrentOffset).Trim();
                                break;
                            case "cargo_42"://币种
                                value = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_Currency", CargoCurrentOffset).Trim();
                                break;
                        }
                        if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_TraCurrency", CargoCurrentOffset).Trim() == "")
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_TraCurrency", CargoCurrentOffset, value);
                        if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_ConCurrency", CargoCurrentOffset).Trim() == "")
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_ConCurrency", CargoCurrentOffset, value);
                        if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_InvoiceCurrency", CargoCurrentOffset).Trim() == "")
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_InvoiceCurrency", CargoCurrentOffset, value);
                        if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).GetValue("U_Currency", CargoCurrentOffset).Trim() == "")
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1).SetValue("U_Currency", CargoCurrentOffset, value);
                    }
                    #endregion

                    #region 根据计费吨标准自动计算计费重量
                    if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_Status", 0).Trim() == "P")
                    {
                        if (pVal.ItemUID == "LCL" && pVal.EventType == BoEventTypes.et_CLICK)
                        {
                            ComboBox cb = this.CurrentForm.Items.Item("T_Standard").Specific as ComboBox;
                            string standard = "1000KGS";
                            if (!String.IsNullOrEmpty(cb.Value))
                            {
                                standard = cb.Value;
                            }
                            Utils.CalcBillingWeight(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1), this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6), standard);
                        }
                        if (pVal.ItemUID == "T_Standard" && pVal.EventType == BoEventTypes.et_COMBO_SELECT)
                        {
                            ComboBox cb = this.CurrentForm.Items.Item("T_Standard").Specific as ComboBox;
                            string standard = "1000KGS";
                            if (!String.IsNullOrEmpty(cb.Value))
                            {
                                standard = cb.Value;
                            }
                            Utils.CalcBillingWeight(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1), this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6), standard);
                        }
                    }
                    #endregion

                    #region 修改计费吨重时同步修改货物表的计费重量
                    if (pVal.ItemUID == "T_Weight" && pVal.ItemChanged)
                    {
                        Utils.SetCargoGrossWeight(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1), SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, pVal.ItemUID).ToString());
                    }
                    #endregion

                    #region 箱型、箱量变化时计算箱量总计描述  添加箱型变化处理 (Modified by WangPeng 12-6-5)
                    if (pVal.ItemUID == "mtxService" && (pVal.ColUID == "col_2" || (pVal.ColUID == "col_1" && pVal.EventType == BoEventTypes.et_COMBO_SELECT)) && pVal.ItemChanged)
                    {
                        this.CurrentForm.Freeze(true);
                        (this.CurrentForm.Items.Item("mtxService").Specific as Matrix).FlushToDataSource();
                        Utils.SetBoxAndCargoQuantityDescription(SBOApp, this.CurrentForm.UniqueID, new Arabic2Engish().NumberToString, "", AVA_OBNO);
                        this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).GetValue("U_BoxQty", 0));
                        this.CurrentForm.Freeze(false);
#if DEBUG
                                                System.Data.DataTable table = SAPBoAddon.B1Assistant.DBDataSource.ReturnDotNetDataTable(this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6));
#endif

                    }
                    #endregion

                    #region 箱量Matrix焦点消失时，显示主表服务类型
                    if (pVal.ItemUID == "mtxService" && pVal.EventType == BoEventTypes.et_LOST_FOCUS)
                    {
                        if (this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_ContainerType", 0).Trim() == "1")
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ServiceType", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO4).GetValue("U_BoxQty", 0));
                        }
                    }
                    #endregion

                    #region 船名航次默认为大写
                    if (pVal.EventType == BoEventTypes.et_LOST_FOCUS)
                    {
                        if (pVal.ItemUID == "406")
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_ShipsName", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_ShipsName", 0).ToUpper());
                        }
                        else if (pVal.ItemUID == "1000045")
                        {
                            this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).SetValue("U_Voyage", 0, this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_Voyage", 0).ToUpper());
                        }
                        //this.CurrentForm.Items.Item(pVal.ItemUID).Specific.Value = this.CurrentForm.Items.Item(pVal.ItemUID).Specific.Value.ToString().ToUpper();
                    }
                    #endregion

                    /*这的事件一定不可以用 et_CLICK 代替，否则你将看到相反的效果
                   设置分单页签是否显示
                 */
                    if (pVal.ItemUID == "914_1" && pVal.EventType == BoEventTypes.et_ITEM_PRESSED)
                    {
                        this.SetTabHidden(pVal.ItemUID, "tab_4");
                    }
                    #region 服务
                    if (pVal.ItemUID == "mtxService" && pVal.ItemChanged)
                    {
                        if (SAPBoAddon.B1Assistant.Item.GetValue(CurrentForm, "cb_opck").ToString() == "N")
                            //箱号、封条号发生变化
                            if (pVal.ColUID == "col_12" || pVal.ColUID == "col_13")
                                if (SAPBoAddon.B1Assistant.Item.GetValue(CurrentForm, "FCL").ToString() == "2" || SAPBoAddon.B1Assistant.Item.GetValue(CurrentForm, "FCL").ToString() == "FCL" || SAPBoAddon.B1Assistant.Item.GetValue(CurrentForm, "FCL").ToString() == "Y")
                                {
                                    GetOrSetBoxAndSealNumber();
                                }
                    }
                    #endregion
                }
                #endregion
                #region 计算计费重
                if ((pVal.ItemUID == "cargo_8" || pVal.ItemUID == "cargo_12") && pVal.ItemChanged)
                {
                    DBDataSource dbds1 = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO1);
                    string GrossWeight = SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, "cargo_8").ToString();
                    if (string.IsNullOrEmpty(GrossWeight)) return;
                    string GrossUnit = SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, "cargo_28").ToString();
                    string GrossRate = string.Empty;
                    string Volume = SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, "cargo_12").ToString();
                    if (string.IsNullOrEmpty(Volume)) return;
                    string ValumeRate = string.Empty;
                    string VolumeUnit = SAPBoAddon.B1Assistant.Item.GetValue(this.CurrentForm, "cargo_32").ToString();

                    SAPbobsCOM.Recordset ors = SBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
                    ors.DoQuery("SELECT U_Rate FROM [@AVA_FF_OPRI] Where U_Type = 'Weigth' And Code = '" + GrossUnit + "'");
                    if (ors.RecordCount > 0)
                    {
                        GrossRate = ors.Fields.Item("U_Rate").Value.ToString();
                    }
                    else
                        GrossRate = "1";
                    ors.DoQuery("SELECT U_Rate FROM [@AVA_FF_OPRI] Where U_Type = 'Volume' And Code = '" + VolumeUnit + "'");
                    if (ors.RecordCount > 0)
                    {
                        ValumeRate = ors.Fields.Item("U_Rate").Value.ToString();
                    }
                    else
                        ValumeRate = "1";
                    string Billing = string.Empty;
                    if ((decimal.Parse(GrossWeight) / decimal.Parse(GrossRate) / 1000) > (decimal.Parse(Volume) / decimal.Parse(ValumeRate)))
                    {
                        Billing = (decimal.Parse(GrossWeight) / decimal.Parse(GrossRate) / 1000).ToString();
                        if (decimal.Parse(Billing) < 1)
                            Billing = "1000";
                        else
                            Billing = (decimal.Parse(Billing) * 1000).ToString();
                        SAPBoAddon.B1Assistant.Item.SetValue(pVal.FormUID, "cargo_30", "KG", BoSearchKey.psk_ByDescription);
                    }
                    else
                    {
                        Billing = (decimal.Parse(Volume) / decimal.Parse(ValumeRate)).ToString();
                        if (decimal.Parse(Billing) < 1)
                            Billing = "1";
                        SAPBoAddon.B1Assistant.Item.SetValue(pVal.FormUID, "cargo_30", "m³", BoSearchKey.psk_ByDescription);
                    }
                    dbds1.SetValue("U_BillingWeight", dbds1.Offset, Billing);
                    SAPBoAddon.B1Assistant.Item.SetValue(pVal.FormUID, "cargo_10", Billing);
                }
                #endregion
                #region 验证箱号窗体
                if (pVal.ItemUID == "mtxService" && pVal.ColUID == "col_12" && pVal.EventType == BoEventTypes.et_VALIDATE)
                {
                    if (this.CurrentForm.Mode == BoFormMode.fm_ADD_MODE || this.CurrentForm.Mode == BoFormMode.fm_UPDATE_MODE)
                    {
                        if ((this.CurrentForm.Items.Item(pVal.ItemUID).Specific as Matrix).GetCellSpecific(pVal.ColUID, pVal.Row).Value.ToString().Length == 0)
                        {
                            SAPbouiCOM.Form containerForm = SAPBoAddon.B1Assistant.Form.LoadToSBOApplciation(System.Windows.Forms.Application.StartupPath + @"\Form\AVA_SE_ContainerForm.srf", "", true);
                            containerForm.DataSources.UserDataSources.Item("ParentUID").Value = this.CurrentForm.UniqueID;
                            containerForm.DataSources.UserDataSources.Item("Matrix").Value = pVal.ItemUID;
                            containerForm.DataSources.UserDataSources.Item("Col").Value = pVal.ColUID;
                            containerForm.DataSources.UserDataSources.Item("Row").Value = pVal.Row.ToString();
                        }
                    }
                }
                #endregion
            }
        }
        #endregion
        #region methods
        /// <summary>
        /// 选择服务页签
        /// </summary>
        private void SwitchServiceTab()
        {
            switch (this.CurrentForm.DataSources.DBDataSources.Item(AVA_OBNO).GetValue("U_ContainerType", 0).Trim())
            {
                case "FCL":
                case "1":
                    CurrentForm.PaneLevel = 21;
                    break;
                case "LCL":
                case "2":
                    CurrentForm.PaneLevel = 22;
                    break;
                case "BREAKBULK":
                case "3":
                    CurrentForm.PaneLevel = 22;
                    break;
                default:
                    CurrentForm.PaneLevel = 21;
                    break;
            }
        }
        ///// <summary>
        ///// 设置Tab是否隐藏
        ///// </summary>
        ///// <author>WangPeng</author>
        //private void SetTabHidden(string ItemUID, string TabUID)
        //{
        //    this.CurrentForm.Freeze(true);
        //    SAPbouiCOM.CheckBox ocheck_IsDBL = this.CurrentForm.Items.Item(ItemUID).Specific;
        //    this.CurrentForm.Items.Item(TabUID).Visible = !ocheck_IsDBL.Checked;
        //    this.CurrentForm.Refresh();
        //    this.CurrentForm.Freeze(false);
        //}
        /// <summary>
        /// 获取服务页签的箱号和封条号，写入分单与主单里
        /// </summary>
        private void GetOrSetBoxAndSealNumber()
        {
            string BoxCode = string.Empty;
            string SealCode = string.Empty;
            List<string> Numbers = new List<string>();
            SAPbouiCOM.Matrix oMtx = CurrentForm.Items.Item("mtxService").Specific;
            for (int i = 1; i < oMtx.VisualRowCount; i++)
            {
                BoxCode = oMtx.GetCellSpecific("col_12", i).String;
                SealCode = oMtx.GetCellSpecific("col_13", i).String;
                Numbers.Add(BoxCode + "\\" + SealCode);
            }
            CurrentForm.DataSources.DBDataSources.Item("@AVA_SE_BNO3").SetValue("U_BoxCode", 0, String.Join("\r\n", Numbers));
            CurrentForm.DataSources.DBDataSources.Item("@AVA_SE_BNO4").SetValue("U_BoxCode", 0, String.Join("\r\n", Numbers));
        }
        /// <summary>
        /// 清除[AVA_BNO6]中的数据
        /// </summary>
        private void ClearDBDS()
        {
            SAPbouiCOM.DBDataSource dbds_BNO6 = this.CurrentForm.DataSources.DBDataSources.Item(AVA_BNO6);
            SAPbouiCOM.Matrix mtx_Service = this.CurrentForm.Items.Item("mtxService").Specific;
            dbds_BNO6.Clear();
            dbds_BNO6.InsertRecord(0);
            dbds_BNO6.SetValue("LineId", dbds_BNO6.Offset, "1");
            mtx_Service.LoadFromDataSourceEx();
        }
        #endregion
    }
}
